﻿namespace EggOfPanKu.Library.Objects
{
    using System;
    using System.Collections.Generic;
    using System.Globalization;
    //using System.Linq;
    using System.Text;
    using System.Xml;
    using System.Xml.Linq;

    public class Personality : Card
    {
        #region Fields

        private string _Chi;
        private string _Clan;
        private string _Cost;
        private string _Force;
        private string _HonorRequirement;
        private string _PersonalHonor;

        #endregion Fields

        #region Constructors

        public Personality(string CardID)
            : base(CardID)
        {
        }

        public Personality(XElement CardNode)
            : base(CardNode)
        {   
            //Set Chi
            Chi = (string)CardNode.Element("chi");
            if (String.IsNullOrEmpty(Chi))
                ParseWarning("Chi");

            //Set Clan
            string clanName = (string)CardNode.Element("clan");
            if (String.IsNullOrEmpty(clanName))
            {
                ParseWarning("Clan");
                clanName = "Unaligned";
            }
            Clan = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(clanName);

            //Set Cost
            Cost = (string)CardNode.Element("cost");
            if (String.IsNullOrEmpty(Cost))
                ParseWarning("Cost");

            //Set Force
            Force = (string)CardNode.Element("force");
            if (String.IsNullOrEmpty(Force))
                ParseWarning("Force");

            //Set Honor Requirement
            HonorRequirement = (string)CardNode.Element("honor_req");
            if (String.IsNullOrEmpty(HonorRequirement))
                ParseWarning("Honor Requirement");

            //Set Personal Honor
            PersonalHonor = (string)CardNode.Element("personal_honor");
            if (String.IsNullOrEmpty(PersonalHonor))
                ParseWarning("Personal Honor");

        }

        #endregion Constructors

        #region Properties

        public override CardType CardType
        {
            get { return CardType.Personality; }
        }

        public string Chi
        {
            get { return _Chi; }
            set { _Chi = value; }
        }

        public string Clan
        {
            get { return _Clan; }
            set { _Clan = value; }
        }

        public string Cost
        {
            get { return _Cost; }
            set { _Cost = value; }
        }

        public override CardDeck DeckType
        {
            get { return CardDeck.Dynasty; }
        }

        public string Force
        {
            get { return _Force; }
            set { _Force = value; }
        }

        public string HonorRequirement
        {
            get { return _HonorRequirement; }
            set { _HonorRequirement = value; }
        }

        public string PersonalHonor
        {
            get { return _PersonalHonor; }
            set { _PersonalHonor = value; }
        }

        #endregion Properties
    }
}